#pragma once

#include "ToolkitsPro.h"
#include "DBXDeviceForward.h"

#include <string>

namespace libconfig { class Setting; }
namespace DBX
{
    using namespace libconfig;
    class TKSPRODLLEXPORT DBXDevice
    {
    public:
        using Ptr = DBXDevicePtr;
        virtual ~DBXDevice();

        virtual void init() = 0;
        virtual void connect() = 0;
        virtual void disconnect() = 0;

        virtual void fromSetting(const Setting &setting) = 0;
        virtual void toSetting(Setting &settins) const = 0;

        virtual void set(const Setting &setting) = 0;
        virtual void get(Setting &settins) const = 0;

        virtual void setConnectionNotify(void *pObj, void(*pHandler)(void *, std::string, bool) = nullptr) {};

        std::string name() const;
        std::string displayName() const;
        int timeout() const;

        bool connected() const;
        void setConnected(bool connected);

    protected:
        explicit DBXDevice();
        void setName(const std::string &name);
        void setDisplayName(const std::string &displayName);
        void setType(const std::string &type);
        void setTimeout(int timeout);

    private:
        DBXDevice(const DBXDevice &) = delete;
        DBXDevice &operator=(const DBXDevice &) = delete;

        class Private;
        Private &p;
    };
} // namespace DBX
